#ifndef STATIC_ASSERT_H
#define STATIC_ASSERT_H

/*  Copyright (c) by Medtronic, Inc., 2012.  */
/*  $Source:$  */
/*  $Revision: 72 $  */
/*  $Date: 2013-08-12 13:54:12 +0000 (Mon, 12 Aug 2013) $  */

// Typically use offsetof() with static asserts, which is defined in stddef.h
#include "stddef.h"


/**********************************************************************
 *
 * Copyright (c) Medtronic, Inc. 2012
 *
 * \file static_assert.h
 * \brief Provides C11 style static asserts.
 * \version $Revision: 72 $
 * \date $Date: 2013-08-12 13:54:12 +0000 (Mon, 12 Aug 2013) $
 *
 * Description: Provides a _Static_assert() macro which supports compile
 * time checking of a required condition.  The macro _Static_assert() is
 * an enhancement that will be present in the C11 standard.  This file
 * provides an equivalent macro for use on C99 compilers..
 *
 * Example:
 * typedef struct myStruct {
 *           uint8_t field1;
 *  __packed uint32_t field2;
 *           uint8_t field3;
 *           uint16_t crc;
 * } S_t;
 *
 * _Static_assert(8==sizeof(S_t), "S_t is packed");
 * _Static_assert(sizeof(S_t)-2 == offsetof(S_t,crc), "crc must be at end of structure.");
 *
 * When expanded, if the condition evaluates to false (==0) the macro attempts to declare an
 * array with size -1, which will produce the following error message during compilation.
 *
 * <file>:<line>:<col>: Error:  #94: the size of an array must be greater than zero
 * _Static_assert(<cond>,<msg>);
 * ^
 *
 * When the condition evaluates to true, the declaration does not produce
 * any additional assembled code, nor does it allocate any memory storage .
 *
 **********************************************************************/
#define _Static_assert(cond,msg) extern char assertion[(cond) ? 1 : -1] // parasoft-suppress PREPROC-01 "Specifically formatted" parasoft-suppress PREPROC-14 "Specifically formatted" parasoft-suppress PREPROC-15 "Specifically formatted" parasoft-suppress MISRA2004-19_7 "Specifically formatted"

#endif

